#!/usr/bin/perl -w

BEGIN   {
    sub getPoints{return '../../' if (!$_[1]);return '../' if (!$_[0]);return '/';}
    (my $file = __FILE__) =~ s/(\/?modules)?(\/?port_mapping)?\/?\w+\.pl$/&getPoints($1,$2)/e;
    $file = './' if $file eq '/';$file .= "bin";
    unshift(@INC, $file);
}


use strict;
use Data::Dumper;
use TWM;
if (isDebug())
{
	use CGI::Carp qw(fatalsToBrowser);
}
my @ips = @ARGV;
my $xml = readModuleConfigFile($cm{ports});
if (ref $xml->{rule} eq 'HASH')
{
	printRow($xml->{rule});
}
else
{
	
	printRow($_) for (@{$xml->{rule}});
}


sub printRow
{
	print "$_[0]->{gw_interface} $_[0]->{gw_port} $_[0]->{proto} $_[0]->{host_ip} $_[0]->{host_port}\n" if ($#ips == -1 || in_array(\@ips, $_[0]->{host_ip}));
}
